<template>
  <div class="container contract-review pb">
    <p class="bread">
      <a href="#/personalcenter">个人中心</a> >
      <a href="#/personalcenter/transac" class="font-s-18">订单管理</a> >
      <a href="javascript:void(0);" class="font-s-16">交易监控</a>
    </p>
    <div class="bg-c-fff box-border">
      <h3 class="tm-title">交易监控服务</h3>
      <step :stepData="stepData" :stepNum="stepNum" @stepRouter="stepRouter"></step>
    </div>
    <div class="content">
      <h3 class=" bg-c-fff">请您就本次服务队律师进行评价，您的评价对我们非常重要，感谢您的配合。</h3>
      <form @submit.prevent="onSubmit">
        <div class="box bg-c-fff">
          <h4>1.合同审查、交易监控流程图绘制阶段</h4>
          <evaluate ref="contractReview" :disabled="!evalua"></evaluate>
          <textarea placeholder="请您留下宝贵意见" v-model="evaluateOne" :readonly="!evalua">
          </textarea>
        </div>
        <div class="box bg-c-fff">
          <h4>2.交易监控进行阶段</h4>
          <evaluate ref="transaction" :disabled="!evalua"></evaluate>
          <textarea placeholder="请您留下宝贵意见" v-model="evaluateTwo" :readonly="!evalua">
          </textarea>
        </div>
        <div class="box bg-c-fff">
          <h4>3.整体服务，满意程度</h4>
          <evaluate ref="whole" :disabled="!evalua"></evaluate>
          <ul>
            <li class="dib">
              <input type="checkbox" id="a" class="vm" value="系统操作繁琐" v-model="checkboxA" :disabled="!evalua">
              <label for="a">系统操作繁琐</label>
            </li>
            <li class="dib">
              <input type="checkbox" id="b" class="vm" value="服务人员态度恶劣" v-model="checkboxB" :disabled="!evalua">
              <label for="b">服务人员态度恶劣</label>
            </li>
            <li class="dib">
              <input type="checkbox" id="c" class="vm" value="系统使用卡顿严重" v-model="checkboxC" :disabled="!evalua">
              <label for="c">系统使用卡顿严重</label>
            </li>
            <li class="dib">
              <input type="checkbox" id="d" class="vm" value="对我无帮助" v-model="checkboxD" :disabled="!evalua">
              <label for="d">对我无帮助</label>
            </li>
          </ul>
          <textarea placeholder="请您留下宝贵意见" v-model="evaluateThree" :readonly="!evalua">
          </textarea>
          <div class="fix btn">
            <div class="flo-right" v-show="evalua">
              <input type="submit" value="提交评价" class="blue-button xl-btn-css tc">
              <input type="button" value="取消" class="blue-button xl-btn-css tc" @click="cancel">
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>
<script type="text/javascript">
import Step from '../components/Step'
import Evaluate from '../components/Evaluate'
export default {
  components: {
    Step,
    Evaluate
  },
  data() {
    return {
      stepNum: 5,
      status: 0,
      stepData: [{
        name: '提交服务申请'
      }, {
        name: '确认资质报告'
      }, {
        name: '合同审查'
      }, {
        name: '绘制流程图'
      }, {
        name: '交易监控'
      }, {
        name: '服务评价'
      }],
      evalua: true,
      evaluateOne: '',
      evaluateTwo: '',
      evaluateThree: '',
      checkboxA: '',
      checkboxB: '',
      checkboxC: '',
      checkboxD: ''
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    stepRouter(i, name) {
      if (i === 0 && this.status >= 1) {
        this.$router.push('/submit-apply?id=' + this.$route.query.id)
      }
      if (i === 1 && this.status >= 2) {
        this.$router.push('/confirm-aptitude?id=' + this.$route.query.id)
      }
      if (i === 2 && this.status >= 3) {
        this.$router.push('/contract-review?id=' + this.$route.query.id)
      }
      if (i === 3 && this.status >= 4) {
        this.$router.push('/transac-service-wait?id=' + this.$route.query.id)
      }
      if (i === 4 && this.status >= 5) {
        this.$router.push('/transactionsurveillance?id=' + this.$route.query.id)
      }
      if (i === 5 && this.status >= 6) {
        this.$router.push('/service-evalua?id=' + this.$route.query.id)
      }
    },
    onSubmit() {
      if (!this.evaluateOne && this.$refs.contractReview.index === 1) {
        this.$toasted.show('请写下您对合同审查、交易监控流程图绘制阶段的意见')
        return
      }
      if (!this.evaluateTwo && this.$refs.transaction.index === 1) {
        this.$toasted.show('请写下您对交易监控进行阶段的意见')
        return
      }
      if (!this.evaluateThree && this.$refs.whole.index === 1) {
        this.$toasted.show('请写下您对整体服务的意见')
        return
      }
      this.$http.post('/evaluate/submit', {
        evaluateId: this.$route.query.id,
        satisfactory: this.$refs.contractReview.index + ',' + this.$refs.transaction.index + ',' + this.$refs.whole.index,
        evaluateType: 3,
        evaluateOne: this.evaluateOne,
        evaluateTwo: this.evaluateTwo,
        evaluatethree: this.evaluateThree + '~@$' + this.checkboxA + ',' + this.checkboxB + ',' + this.checkboxC + ',' + this.checkboxD
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.$toasted.show('提交成功，感谢您留下宝贵意见')
          this.$router.push('/personalcenter/transac')
        } else {
          this.$toasted.show(data.data.msg)
          console.log(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
        this.$toasted.show('网络错误')
      })
    },
    getData() {
      this.$http.post('/transactionMonitorSer/business/read/detail', {
        id: this.$route.query.id
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.status = data.data.data.status
          if (data.data.data.evaluateList) {
            this.evalua = false
            this.$refs.contractReview.index = data.data.data.evaluateList[0].satisfactory.split(',')[0]
            this.$refs.transaction.index = data.data.data.evaluateList[0].satisfactory.split(',')[1]
            this.$refs.whole.index = data.data.data.evaluateList[0].satisfactory.split(',')[2]
            this.evaluateOne = data.data.data.evaluateList[0].evaluateContentOne
            this.evaluateTwo = data.data.data.evaluateList[0].evaluateContentTwo
            let contentThree = data.data.data.evaluateList[0].evaluateContentThree
            this.evaluateThree = contentThree.split('~@$')[0]
            this.checkboxA = contentThree.split('~@$')[1].split(',')[0]
            this.checkboxB = contentThree.split('~@$')[1].split(',')[1]
            this.checkboxC = contentThree.split('~@$')[1].split(',')[2]
            this.checkboxD = contentThree.split('~@$')[1].split(',')[3]
          }
        }
      }).catch(err => {
        console.log(err)
        this.$toasted.show('网络出错')
      })
    },
    cancel() {
      this.$refs.contractReview.index = 3
      this.$refs.transaction.index = 3
      this.$refs.whole.index = 3
      this.evaluateOne = ''
      this.evaluateTwo = ''
      this.evaluateThree = ''
      this.checkboxA = ''
      this.checkboxB = ''
      this.checkboxC = ''
      this.checkboxD = ''
    }
  }
}

</script>
<style type="text/css" scoped>
.box-border {
  border: 1px solid #ddd;
}

.tm-title {
  line-height: 40px;
  padding-left: 35px;
  font-size: 14px;
  color: #282828;
  border-bottom: 1px solid #ddd;
}

.content .box {
  padding: 20px 40px;
  margin-bottom: 15px;
}

.content .box .white-button {
  width: 100px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  margin: 5px 74px 5px 0;
}

.content .box .box-border-top {
  border-top: 1px solid #ddd;
}

.pb {
  padding-bottom: 50px;
}

.content h3 {
  border-bottom: 1px solid #dddddd;
  color: #282828;
  line-height: 40px;
  padding-left: 40px;
  font-size: 14px;
  margin-top: 15px;
}

.content h4 {
  font-weight: bold;
  color: #282828;
  line-height: 40px;
}

.content .box ul li {
  margin: 23px 20px 10px 0;
}

textarea {
  width: 100%;
  height: 120px;
  margin-top: 15px;
  border-color: #ddd;
  padding: 10px 7px;
}

.content .box .btn input {
  margin: 20px 5px 30px 40px;
}

</style>
